package com.isoftstone.merchant.service.role.impl;

import com.isoftstone.common.Page;
import com.isoftstone.merchant.dao.role.PRoleMapper;
import com.isoftstone.merchant.entity.role.PRole;
import com.isoftstone.merchant.service.role.IPRoleService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class PRoleService implements IPRoleService {
    @Autowired
    PRoleMapper pRoleMapper;

    public PRole getRoleById(String roleId) throws Exception {
        return pRoleMapper.getRoleById(roleId);
    }

    public PRole getRoleByCode(String roleCode) throws Exception {
        return pRoleMapper.getRoleByCode(roleCode);
    }

    public List<PRole> getRolelistPage(Page page) throws Exception {
        return pRoleMapper.getRolelistPage(page);
    }

    @Transactional
    public void saveRole(PRole pRole) throws Exception {
        pRoleMapper.saveRole(pRole);
    }

    @Transactional
    public void updateRole(PRole pRole) throws Exception {
        pRoleMapper.updateRole(pRole);
    }

    @Transactional
    public void deleteRole(Integer roleId) throws Exception {
        pRoleMapper.deleteRole(roleId);
    }

    @Override
    public List<PRole> getSysRole(@Param("comCode") String comCode) throws Exception {
        return pRoleMapper.getSysRole(comCode);
    }

    @Override
    public List<PRole> getCompanyRoles(String empCode,String comCode) throws Exception {
        return pRoleMapper.getCompanyRoles(empCode, comCode);
    }

    public List<PRole> getRole() throws Exception {
        return pRoleMapper.getRole();
    }
}
